<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Appcontent extends CI_Controller {
	
	function __construct() {
		parent::__construct(); 
		$this->load->library('session'); 
		$this->load->helper('url'); 
		$this->load->library('pagination');
		$this->load->helper(array('form', 'url')); 
		@session_start();
	} 
	
	public function index(){}
	
	// Xu ly Json lay du lieu tu app ------------Liet ke danh sach---------------
	public function blogradio($type=null,$cate=null){
		$this->load->model('content_model');
		$response = array();
		$response["items"] = array();
		$lists = $this->content_model->showallcontent_catetype($type,$cate); 
		foreach($lists as $value){
				$item = array();
				$item['id']=$value->id;
    			$item['namecontent']=$value->namecontent;
    			$item['description']=$value->description;
    			$item['images']=$value->images;
				$item['coins'] =$value->coins;
				array_push($response["items"], $item);
			
		}
		 $response["success"] = 1;
		echo json_encode($response);
	}
	// Xu ly Json lay du lieu tu app ------------Lay chi tiet----------------
	
	public function getdetails($id=null){
		$this->load->model('content_model');
		$result = $this->content_model->show_detailscontent($id);
		$response = array();
		$response["items"] = array();
		if($result != null) {
		foreach($result as $value){
				$item = array(); 
				$item['cateid']=$value->cateid;
				$item['typeid']=$value->typeid;
    			$item['namecontent']=$value->namecontent;
    			$item['description']=$value->description;
    			$item['images']=$value->images;
				$item['coins'] =$value->coins;
				$item['ifiles'] = $value->ifiles;
				$item['ifiles_2'] = $value->ifiles_2;
				$item['ifiles_3'] = $value->ifiles_3;
				$item['datecreated'] = $value->datecreated; 
				array_push($response["items"], $item); 
		}
		 $response["success"] = 1;
		 echo json_encode($response);
		 }else{ 
			$response["success"] = 0;
			$response["message"] = "Null"; 
			echo json_encode($response);
		 }
	}
	
	
	
	public function user($id=null,$type=null){ 
		$this->load->model('app_model');
 
		if(!isset($_GET['id']))
		{
			echo json_encode(array(
				"title"		=> "Danh sách video",
				"quangcao"	=> "Danh sách video",
				"dauso"     => "0932239222",
				"cuphap"    => "DG",
				"res"		=> array(
					array(
						"name"	=>"Phim 1", 
						"img"	=>"https://encrypted-tbn1.google.com/images?q=tbn:ANd9GcQqbAaZLzqcDFDh8MHYEotMrmJHYgSdP1UeEJvJrMsNzEsmY7q0KA", 
						"id"	=>"1", 
						"nguon"	=>"Lượt tải: 1467",
						"cuphap"=>"DG",
						"dauso" =>"6789"
						
					) 
				)
			));
		}
		else
		{
			$link1="";
			$link2="";
			$desc="";
			switch($_GET["id"])
			{
				case "1":
					$link2="http://www.youtube.com/watch?v=N6ViN_zHOxo";
					$desc="Phim 1";
					break;
				case "2":
					$link2="http://www.youtube.com/watch?v=WD0ZM03rz2c";
					$desc="Phim 2";
					break; 
			}
			echo json_encode(array(
				"res" => array(
					array("name"=>"Xem ".$desc,"url"=>$link2,"motanoidung"=>$desc)
				)
			));
		}
	}
 
	
	
	public function content($user){
		$this->load->model('app_content');
		$arr = $this->app_content->getall_byusername($user); 
		if(!isset($_GET['id']))
		{
			echo json_encode(array(
				"title"		=> "List of Videos",
				"quangcao"	=> "Advertisments",
				"dauso"     => "8729",
				"cuphap"    => "mov",
				"res"		=> json_encode($arr)
				));
		}
		else
		{
			$link1="";
			$link2="";
			$desc="";
			switch($_GET["id"])
			{
				case "1":
					$link2="http://www.youtube.com/watch?v=E5zTyQBi8HA&feature=related";
					$desc="Cướp biển Caribe - Danh hài Hoài Linh";
					break;
				case "2":
					$link2="http://www.youtube.com/watch?v=rsfwh5L548o";
					$desc="Bố già hôngkong ";
					break;
				case "3":
					$link2="http://www.youtube.com/watch?v=0qu6NJU-mRI";
					$desc="Aphi A ký ";
					break;
				case "4":
					$link2="http://www.youtube.com/watch?v=NpQUENk1Lts";
					$desc="Người vận chuyển 4 - trailer ";
					break;
				case "5":
					$link2="http://www.youtube.com/watch?v=9JyWGMv7ROo";
					$desc=" Anonymous - Hackers World [HD] ";
					break;
				case "6":
					$link2="http://www.youtube.com/watch?v=BM-UC5d_dvU";
					$desc="Tiên kiếm kì hiệp bộ 3-0";
					break;
				case "7":
					$link2="http://www.youtube.com/watch?v=ng4pwquBcbI";
					$desc="Tiên kiếm kì hiệp bộ 3 -1";
					break;
				case "8":
					$link2="http://www.youtube.com/watch?v=Ip2eq_7R5aw";
					$desc="Trường học bá vương";
					break;
				case "9":
					$link2="http://www.youtube.com/watch?v=rMDWf8p-clc";
					$desc="Hỏi xoáy đáp xoay";
					break;
				case "10":
					$link2="http://www.youtube.com/watch?v=u8oBpqRlHG0";
					$desc="Tứ đại danh bổ ";
					break;
				case "11":
					$link2="http://www.youtube.com/watch?v=cqi-tq7UEWM";
					$desc="Kẻ huỷ diệt";
					break;
				case "12":
					$link2="http://www.youtube.com/watch?v=qxMd3YoT2Dw";
					$desc="Bá vương học đường";
					break;
				case "13":
					$link2="http://www.youtube.com/watch?v=NsctpsDX-wA";
					$desc=" Biệt Đội Thần Long (Hồng Kim Bảo) Thuyết Minh ";
					break;
				case "14":
					$link2="http://www.youtube.com/watch?v=EDwW43qVLmE";
					$desc="Ma Quỷ Hồng Kông ";
					break;
				case "15":
					$link2="http://www.youtube.com/watch?v=o4xsMU7Hdcs";
					$desc="Cô gái đồ long ";
					break;
				case "16":
					$link2="http://www.youtube.com/watch?v=otGpHLazk4I";
					$desc=" The Victoria's Secret Fashion Show 2009 FULL HD SHOW ";
					break;
				case "17":
					$link2="http://www.youtube.com/watch?v=GTnnSJ3cbSE";
					$desc=" Victoria's Secret Fashion Show 2008 Full Video HD-1080p ";
					break;
				case "18":
					$link2="http://www.youtube.com/watch?v=zTAxspxXMys";
					$desc="Victoria's Secret Fashion Show 2005 Full Video HD ";
					break;
				case "19":
					$link2="http://www.youtube.com/watch?v=fUxiRd9VwXA";
					$desc=" Victoria's Secret Fashion Show 2011 Full Video HD ";
					break;
				case "20":
					$link2="http://www.youtube.com/watch?v=dDyWWA40r3o";
					$desc="Gặp nhau cuối năm Full 2012";
					break;
			}
			echo json_encode(array(
				"res" => array(
			array("name"=>"Xem ".$desc,"url"=>$link2,"motanoidung"=>$desc)
			)
			));
		}
	}
	
	
	
}